// useLiveStore.js
import { defineStore } from 'pinia';
import axios from 'axios';

export const useLiveStore = defineStore('live', {
  state: () => ({
    lives: [],
    liveDetails: null,
  }),
  actions: {
    async fetchLives(tabId, pageIndex = 1) {
      const response = await axios.get(`https://apis.netstart.cn/mogujie/live/tabList?tabId=${tabId}&pageIndex=${pageIndex}`);
      if (response.data.ret === 'SUCCESS') {
        this.lives = response.data.data.lives;
      }
    },
    async fetchLiveDetails(roomId, actorId) {
      const response = await axios.get(`https://apis.netstart.cn/mogujie/live/actorLiveInfo?roomId=${roomId}&actorId=${actorId}`);
      if (response.data.ret === 'SUCCESS') {
        this.liveDetails = response.data.data;
      }
    },
  },
});